package net.zjitc.controller;

import net.zjitc.aop.Pager;
import net.zjitc.pojo.api.Result;
import net.zjitc.pojo.dto.query.extend.BookshelfQueryDto;
import net.zjitc.pojo.entity.BookShelf;
import net.zjitc.service.BookshelfService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//书架
@RestController
@RequestMapping(value = "/bookshelf")
public class BookshelfController {

    @Resource
    private BookshelfService bookshelfService;

    //书架新增
    @PostMapping(value = "/save")
    public Result<Void> save(@RequestBody BookShelf bookShelf) {
        return bookshelfService.save(bookShelf);
    }

    //删除
    @PostMapping(value = "/batchDelete")
    public Result<Void> batchDelete(@RequestBody List<Integer> ids) {
        return bookshelfService.batchDelete(ids);
    }

    //修改
    @PutMapping(value = "/update")
    public Result<Void> update(@RequestBody BookShelf bookShelf) {
        return bookshelfService.update(bookShelf);
    }

    //查询
    @Pager
    @PostMapping(value = "/query")
    public Result<List<BookShelf>> query(@RequestBody BookshelfQueryDto bookshelfQueryDto) {
        return bookshelfService.query(bookshelfQueryDto);
    }

}
